home *** CD-ROM | disk | FTP | other *** search
- /************************************************************
-
- File: SCSI.h
-
- Contains:
- This file contains constants and data structures that are used by
- drivers to interface with both the old and new SCSI Managers.
-
- Written by:
- Paul Wolf, Clinton Bauder, Henry Kannapell
-
- Copyright: © 1986-1994 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <SM3> 2/11/94 pdw Rolled in all of the SCSI Manager 4.3 stuff from the old ACAM.h
- file.
- ************************************************************/
-
-
- #ifndef __SCSI__
- #define __SCSI__
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #ifndef __TRAPS__
- #include <Traps.h>
- #endif
-
-
- /*——————————————————————— Old SCSI Manager Interface ———————————————————————*/
-
- /* TIB opcodes */
-
- enum {
- scInc = 1,
- scNoInc= 2,
- scAdd = 3,
- scMove = 4,
- scLoop = 5,
- scNop = 6,
- scStop = 7,
- scComp = 8
- };
-
-
- /* SCSI Manager errors */
-
- enum {
- scCommErr = 2, /* communications error, operation timeout */
- scArbNBErr = 3, /* arbitration timeout waiting for not BSY */
- scBadParmsErr = 4, /* bad parameter or TIB opcode */
- scPhaseErr = 5, /* SCSI bus not in correct phase for attempted operation */
- scCompareErr = 6, /* data compare error */
- scMgrBusyErr = 7, /* SCSI Manager busy */
- scSequenceErr = 8, /* attempted operation is out of sequence */
- scBusTOErr = 9, /* CPU bus timeout */
- scComplPhaseErr= 10 /* SCSI bus wasn't in Status phase */
- };
-
-
- /* Signatures */
-
- enum {
- sbSIGWord = 0x4552, /* signature word for Block 0 ('ER') */
- sbMac = 1, /* system type for Mac */
- pMapSIG = 0x504D, /* partition map signature ('PM') */
- pdSigWord = 0x5453
- };
-
- #define oldPMSigWord pdSigWord
- #define newPMSigWord pMapSIG
-
-
- /* Driver Descriptor Map */
-
- struct Block0 {
- unsigned short sbSig; /* unique value for SCSI block 0 */
- unsigned short sbBlkSize; /* block size of device */
- unsigned long sbBlkCount; /* number of blocks on device */
- unsigned short sbDevType; /* device type */
- unsigned short sbDevId; /* device id */
- unsigned long sbData; /* not used */
- unsigned short sbDrvrCount; /* driver descriptor count */
- unsigned long ddBlock; /* 1st driver's starting block */
- unsigned short ddSize; /* size of 1st driver (512-byte blks) */
- unsigned short ddType; /* system type (1 for Mac+) */
- unsigned short ddPad[243]; /* ARRAY[0..242] OF INTEGER; not used */
- };
-
- typedef struct Block0 Block0;
-
-
- /* Partition Map Entry */
-
- struct Partition {
- unsigned short pmSig; /* unique value for map entry blk */
- unsigned short pmSigPad; /* currently unused */
- unsigned long pmMapBlkCnt; /* # of blks in partition map */
- unsigned long pmPyPartStart; /* physical start blk of partition */
- unsigned long pmPartBlkCnt; /* # of blks in this partition */
- unsigned char pmPartName[32]; /* ASCII partition name */
- unsigned char pmParType[32]; /* ASCII partition type */
- unsigned long pmLgDataStart; /* log. # of partition's 1st data blk */
- unsigned long pmDataCnt; /* # of blks in partition's data area */
- unsigned long pmPartStatus; /* bit field for partition status */
- unsigned long pmLgBootStart; /* log. blk of partition's boot code */
- unsigned long pmBootSize; /* number of bytes in boot code */
- unsigned long pmBootAddr; /* memory load address of boot code */
- unsigned long pmBootAddr2; /* currently unused */
- unsigned long pmBootEntry; /* entry point of boot code */
- unsigned long pmBootEntry2; /* currently unused */
- unsigned long pmBootCksum; /* checksum of boot code */
- unsigned char pmProcessor[16]; /* ASCII for the processor type */
- unsigned short pmPad[188]; /* 512 bytes long currently unused */
- };
-
- typedef struct Partition Partition;
-
-
- /* TIB instruction */
-
- struct SCSIInstr {
- unsigned short scOpcode;
- unsigned long scParam1;
- unsigned long scParam2;
- };
-
- typedef struct SCSIInstr SCSIInstr;
-
-
- #ifdef __cplusplus
- extern "C" {
- #endif
- pascal OSErr SCSIReset(void)
- = {0x4267,0xA815};
- pascal OSErr SCSIGet(void)
- = {0x3F3C,0x0001,0xA815};
- pascal OSErr SCSISelect(short targetID)
- = {0x3F3C,0x0002,0xA815};
- pascal OSErr SCSICmd(Ptr buffer,short count)
- = {0x3F3C,0x0003,0xA815};
- pascal OSErr SCSIRead(Ptr tibPtr)
- = {0x3F3C,0x0005,0xA815};
- pascal OSErr SCSIRBlind(Ptr tibPtr)
- = {0x3F3C,0x0008,0xA815};
- pascal OSErr SCSIWrite(Ptr tibPtr)
- = {0x3F3C,0x0006,0xA815};
- pascal OSErr SCSIWBlind(Ptr tibPtr)
- = {0x3F3C,0x0009,0xA815};
- pascal OSErr SCSIComplete(short *stat,short *message,unsigned long wait)
- = {0x3F3C,0x0004,0xA815};
- pascal short SCSIStat(void)
- = {0x3F3C,0x000A,0xA815};
- pascal OSErr SCSISelAtn(short targetID)
- = {0x3F3C,0x000B,0xA815};
- pascal OSErr SCSIMsgIn(short *message)
- = {0x3F3C,0x000C,0xA815};
- pascal OSErr SCSIMsgOut(short message)
- = {0x3F3C,0x000D,0xA815};
- #ifdef __cplusplus
- }
- #endif
-
-
-
- /*——————————————————————— New SCSI Manager Interface ———————————————————————*/
-
-
- enum {
- scsiVERSION = 43
- };
-
- /********************************************************************/
- // Defines for the SCSIMgr function codes
- /********************************************************************/
-
- enum
- {
- //------------ Common Functions ------------
-
- SCSINop = 0x00, // Execute nothing
- SCSIExecIO = 0x01, // Execute the specified IO
- SCSIBusInquiry = 0x03, // Get parameters for entire path of HBAs
- SCSIReleaseQ = 0x04, // Release the frozen SIM queue for particular LUN
- SCSISetAsyncCallback = 0x05, // Set async event call back
-
- //------------ Control Functions ------------
-
- SCSIAbortCommand = 0x10, // Abort the selected Control Block
- SCSIResetBus = 0x11, // Reset the SCSI bus
- SCSIResetDevice = 0x12, // Reset the SCSI device
- SCSITerminateIO = 0x13, // Terminate any pending IO
-
- //------------ Target Mode Functions ------------
-
- SCSIEnableLUN = 0x30, // Enable LUN, Target mode support
- SCSITargetIO = 0x31, // Execute the target IO request
-
- //------------ Apple Added ------------
-
- SCSIGetVirtualIDInfo = 0x80, // Find out which bus old ID is on
- SCSIGenerateInterleaveID = 0x81, // Generate a new interleave factor
- SCSILoadDriver = 0x82, // Load a driver for a device ident
- SCSIOldCall = 0x84, // XPT->SIM private call for old-API
- SCSICreateRefNumXref = 0x85, // Register a DeviceIdent to drvr RefNum xref
- SCSILookupRefNumXref = 0x86, // Get DeviceIdent to drvr RefNum xref
- SCSIRemoveRefNumXref = 0x87, // Remove a DeviceIdent to drvr RefNum xref
- SCSIRegisterWithNewXPT = 0x88 // XPT has changed - SIM needs to re-register itself
-
- //------------ 3rd-party Vendor Unique ------------
-
- // 0xC0 thru 0xFF
- };
-
-
- /********************************************************************/
- /* SCSI Parameter Block Elements */
- /********************************************************************/
-
- typedef pascal void (*CallbackProc) (void * ioPtr);
-
-
- //————— Allocation length defines for some of the fields —————
-
- enum {
- handshakeDataLength = 8, // Handshake data length
- maxCDBLength = 16, // Space for the CDB bytes/pointer
- vendorIDLength = 16 // ASCII string len for Vendor ID
- };
-
- //————— Define DeviceIdent structure —————
-
- typedef struct DeviceIdent
- {
- unsigned char diReserved; // reserved
- unsigned char bus; // SCSI - Bus #
- unsigned char targetID; // SCSI - Target SCSI ID
- unsigned char LUN; // SCSI - LUN
- } DeviceIdent;
-
-
- //————— Command Descriptor Block structure —————
-
- typedef union CDB
- {
- unsigned char * cdbPtr; // ptr to the CDB bytes to send, or…
- unsigned char cdbBytes[ maxCDBLength ]; // actual CDB to send
- } CDB, *CDBPtr;
-
-
- //————— Scatter/gather list element —————
-
- typedef struct SGRecord
- {
- Ptr SGAddr;
- unsigned long SGCount;
- } SGRecord;
-
-
-
-
- /********************************************************************/
- /* SCSI Parameter Block Definitions */
- /********************************************************************/
-
- //====== Common SCSI PB header fields macro ======
-
- #define SCSIPBHdr \
- struct SCSIHdr * qLink; /* (internal) Q link to next PB */ \
- short scsiReserved1; /* -> reserved for input */ \
- unsigned short scsiPBLength; /* -> Length of the entire PB */ \
- unsigned char scsiFunctionCode; /* -> function selector */ \
- unsigned char scsiReserved2; /* <- reserved for output */ \
- OSErr scsiResult; /* <- Returned result */ \
- DeviceIdent scsiDevice; /* -> Device Identifier (bus+target+lun)*/ \
- CallbackProc scsiCompletion; /* -> Callback on completion function */ \
- unsigned long scsiFlags; /* -> assorted flags */ \
- unsigned char * scsiDriverStorage; /* <> Ptr for driver private use */ \
- Ptr scsiXPTprivate; /* private field for use in XPT */ \
- long scsiReserved3; /* reserved */
- // end of SCSIPBHdr
-
-
- //—————————————— SCSI PB Header ——————————————
-
- typedef struct SCSIHdr
- {
- SCSIPBHdr
- } SCSIHdr;
-
- typedef struct SCSI_PB
- {
- SCSIPBHdr
- } SCSI_PB;
-
-
- //—————————————— SCSI I/O Request PB ——————————————
-
- #define SCSI_IO_Macro \
- SCSIPBHdr /* Header information fields */ \
- unsigned short scsiResultFlags; /* <- Flags which modify the scsiResult field */ \
- unsigned short scsiInterleaveID; /* -> used to designate interleavability of request */ \
- unsigned char * scsiDataPtr; /* -> Pointer to the data buffer or the S/G list */ \
- unsigned long scsiDataLength; /* -> Data transfer length */ \
- unsigned char * scsiSensePtr; /* -> Ptr to autosense data buffer */ \
- unsigned char scsiSenseLength; /* -> size of the autosense buffer */ \
- unsigned char scsiCDBLength; /* -> Number of bytes for the CDB */ \
- unsigned short scsiSGListCount; /* -> num of scatter gather list entries */ \
- unsigned long scsiReserved4; /* <- reserved for output */ \
- unsigned char scsiSCSIstatus; /* <- Returned scsi device status */ \
- char scsiSenseResidual; /* <- Autosense residual length */ \
- unsigned short scsiReserved5; /* <- reserved for output */ \
- long scsiDataResidual; /* <- Returned Transfer residual length */ \
- CDB scsiCDB; /* -> Actual CDB or pointer to CDB */ \
- long scsiTimeout; /* -> Timeout value (Time Mgr format) (CAM timeout) */ \
- unsigned char * scsiMessagePtr; /* -> Pointer to the message buffer -target md only */ \
- unsigned short scsiMessageLen; /* -> Num of bytes in the msg bfr -target md only */ \
- unsigned short scsiIOFlags; /* -> additional I/O flags */ \
- unsigned char scsiTagAction; /* -> What to do for tag queuing */ \
- unsigned char scsiReserved6; /* -> reserved for input */ \
- unsigned short scsiReserved7; /* -> reserved for input */ \
- unsigned short scsiSelectTimeout; /* -> Select timeout value */ \
- unsigned char scsiDataType; /* -> Data description type (i.e. buffer, TIB, S/G) */ \
- unsigned char scsiTransferType; /* -> Transfer type (i.e. Blind vs Polled) */ \
- unsigned long scsiReserved8; /* -> reserved for input */ \
- unsigned long scsiReserved9; /* -> reserved for input */ \
- unsigned short scsiHandshake[handshakeDataLength]; /* -> handshaking points (null term'd) */ \
- unsigned long scsiReserved10; /* -> reserved for input */ \
- unsigned long scsiReserved11; /* -> reserved for input */ \
- struct SCSI_IO *scsiCommandLink; /* -> Ptr to the next PB in linked cmd chain */ \
- \
- unsigned char scsiSIMpublics[8]; /* -> reserved for input to 3rd-party SIMs */ \
- unsigned char scsiAppleReserved6[8]; /* -> reserved for input */ \
- \
- /* XPT layer privates (for old-API emulation) */ \
- \
- unsigned short scsiCurrentPhase; /* <- phase upon completing old call */ \
- short scsiSelector; /* -> selector specified in old calls */ \
- OSErr scsiOldCallResult; /* <- result of old call */ \
- unsigned char scsiSCSImessage; /* <- Returned scsi device message (for SCSIComplete)*/ \
- unsigned char XPTprivateFlags; /* <> various flags */ \
- unsigned char XPTextras[12]; /* */
-
- // end of SCSI_IO_Macro
-
-
- typedef struct SCSI_IO
- {
- SCSI_IO_Macro
- } SCSI_IO;
-
- #define SCSIExecIOPB SCSI_IO
-
-
-
-
- //—————————————— Bus inquiry PB ——————————————
- typedef struct SCSIBusInquiryPB
- {
- SCSIPBHdr // Header information fields
- unsigned short scsiEngineCount; // <- Number of engines on HBA
- unsigned short scsiMaxTransferType; // <- Number of transfer types for this HBA
-
- unsigned long scsiDataTypes; // <- which data types are supported by this SIM
-
- unsigned short scsiIOpbSize; // <- Size of SCSI_IO PB for this SIM/HBA
- unsigned short scsiMaxIOpbSize; // <- Size of max SCSI_IO PB for all SIM/HBAs
-
- unsigned long scsiFeatureFlags; // <- Supported features flags field
-
- unsigned char scsiVersionNumber; // <- Version number for the SIM/HBA
- unsigned char scsiHBAInquiry; // <- Mimic of INQ byte 7 for the HBA
- unsigned char scsiTargetModeFlags; // <- Flags for target mode support
- unsigned char scsiScanFlags; // <- Scan related feature flags
-
- unsigned long scsiSIMPrivatesPtr; // <- Ptr to SIM private data area
- unsigned long scsiSIMPrivatesSize; // <- Size of SIM private data area
- unsigned long scsiAsyncFlags; // <- Event cap. for Async Callback
-
- unsigned char scsiHiBusID; // <- Highest path ID in the subsystem
- unsigned char scsiInitiatorID; // <- ID of the HBA on the SCSI bus
- unsigned short scsiBIReserved0;
-
- unsigned long scsiBIReserved1; // <-
- unsigned long scsiFlagsSupported; // <- which scsiFlags are supported
-
- unsigned short scsiIOFlagsSupported; // <- which scsiIOFlags are supported
- unsigned short scsiWeirdStuff; // <-
- unsigned short scsiMaxTarget; // <- maximum Target number supported
- unsigned short scsiMaxLUN; // <- maximum Logical Unit number supported
-
- char scsiSIMVendor[ vendorIDLength ]; // <- Vendor ID of SIM (or XPT if bus<FF)
- char scsiHBAVendor[ vendorIDLength ]; // <- Vendor ID of the HBA
- char scsiControllerFamily[ vendorIDLength ]; // <- Family of SCSI Controller
- char scsiControllerType[ vendorIDLength ]; // <- Specific Model of SCSI Controller used
-
- char scsiXPTversion[4]; // <- version number of XPT
- char scsiSIMversion[4]; // <- version number of SIM
- char scsiHBAversion[4]; // <- version number of HBA
-
- unsigned char scsiHBAslotType; // <- type of "slot" that this HBA is in
- unsigned char scsiHBAslotNumber; // <- slot number of this HBA
- unsigned short scsiSIMsRsrcID; // <- resource ID of this SIM
-
- unsigned short scsiBIReserved3; // <-
- unsigned short scsiAdditionalLength; // <- additional BusInquiry PB len
- } SCSIBusInquiryPB;
-
-
- //—————————————— Abort SIM Request PB ——————————————
- typedef struct SCSIAbortCommandPB
- {
- SCSIPBHdr // Header information fields
- SCSI_IO * scsiIOptr; // Pointer to the PB to abort
- } SCSIAbortCommandPB; // <SM3>
-
-
- //—————————————— Terminate I/O Process Request PB ——————————————
- typedef struct SCSITerminateIOPB
- {
- SCSIPBHdr // Header information fields
- SCSI_IO * scsiIOptr; // Pointer to the PB to terminate
- } SCSITerminateIOPB; // <SM3>
-
-
- //—————————————— Reset SCSI Bus PB ——————————————
- typedef struct SCSIResetBusPB
- {
- SCSIPBHdr // Header information fields
- } SCSIResetBusPB; // <SM3>
-
-
- //—————————————— Reset SCSI Device PB ——————————————
- typedef struct SCSIResetDevicePB
- {
- SCSIPBHdr // Header information fields
- } SCSIResetDevicePB; // <SM3>
-
-
- //—————————————— Release SIM Queue PB ——————————————
- typedef struct SCSIReleaseQPB
- {
- SCSIPBHdr // Header information fields
- } SCSIReleaseQPB;
-
-
- //—————————————— Set Async Event Callback PB ——————————————
- typedef struct SCSISetAsyncCallbackPB
- {
- SCSIPBHdr // Header information fields
- unsigned long scsiEventFlags; // -> events to be notified of
- void (*scsiEventCallback)(); // -> routine to call when event occurs
- unsigned char * scsiEventInfoPtr; // -> ptr to buffer for additional info
- unsigned char scsiEventInfoLen; // -> length of buffer
- unsigned char scsiReserved11; //
- unsigned short scsiReserved12; //
- } SCSISetAsyncCallbackPB;
-
-
- //—————————————— SCSI Get Virtual ID Info PB ——————————————
- typedef struct SCSIGetVirtualIDInfoPB
- {
- SCSIPBHdr // Header information fields
- unsigned short scsiOldCallID; // -> SCSI ID of device in question
- Boolean scsiExists; // <- true if device exists
- } SCSIGetVirtualIDInfoPB;
-
-
- //—————————————— SCSI Generate Interleave ID PB ——————————————
- typedef struct SCSIGenerateInterleaveIDPB
- {
- SCSIPBHdr // Header information fields
- unsigned short scsiInterleaveID; // <- SCSI ID of device in question
- unsigned short scsiReserved13; //
- } SCSIGenerateInterleaveIDPB;
-
-
- //—————————————— Create/Lookup/Remove RefNum for Device PB ——————————————
- typedef struct SCSIDriverPB
- {
- SCSIPBHdr // Header information fields
- short scsiDriver; // -> DriverRefNum, For SetDriver
- // <- For GetNextDriver
- unsigned short scsiDriverFlags; // <> Details of driver/device
- DeviceIdent scsiNextDevice; // <- DeviceIdent of the NEXT Item in the list
- } SCSI_Driver_PB;
-
-
- //—————————————— Load Driver PB ——————————————
- typedef struct SCSILoadDriverPB
- {
- SCSIPBHdr // Header information fields
- short scsiLoadedRefNum; // <- SIM returns refnum of driver
- Boolean scsiDiskLoadFailed; // -> if true, indicates call after failure to load
- } SCSILoadDriverPB; //
-
- //======================================================================
-
- /******************************************************************************/
- // Values for the fields in SCSI PBs
- /******************************************************************************/
-
- //———————————————————————————————————————————————————————————————————————————————————
- // Defines for the scsiTransferType field
- //———————————————————————————————————————————————————————————————————————————————————
-
- enum {
- scsiTransferBlind = 0,
- scsiTransferPolled
- };
-
- //———————————————————————————————————————————————————————————————————————————————————
- // Defines for the scsiDataType field
- //———————————————————————————————————————————————————————————————————————————————————
-
- enum {
- scsiDataBuffer = 0, // single contiguous buffer supplied
- scsiDataTIB = 1, // TIB supplied (ptr in scsiDataPtr)
- scsiDataSG = 2 // scatter/gather list supplied
- };
-
- //———————————————————————————————————————————————————————————————————————————————————
- // Defines for the SCSIMgr scsiResult field in the PB header.
- // $E100 thru E1FF
- // -$1EFF thru -1E00
- // -#7935 thru -7681
- //———————————————————————————————————————————————————————————————————————————————————
-
- #define scsiErrorBase -7936 // = 0xE100
-
- enum {
- scsiRequestInProgress = 1, // 1 = PB request is in progress
-
- // Execution failed 00-2F
- scsiRequestAborted = (scsiErrorBase+0x02), // -7934 = PB request aborted by the host
- scsiUnableToAbort = (scsiErrorBase+0x03), // -7933 = Unable to Abort PB request
- scsiNonZeroStatus = (scsiErrorBase+0x04), // -7932 = PB request completed with an err
- scsiUnused05 = (scsiErrorBase+0x05), // -7931 =
- scsiUnused06 = (scsiErrorBase+0x06), // -7930 =
- scsiUnused07 = (scsiErrorBase+0x07), // -7929 =
- scsiUnused08 = (scsiErrorBase+0x08), // -7928 =
- scsiUnableToTerminate = (scsiErrorBase+0x09), // -7927 = Unable to Terminate I/O PB req
- scsiSelectTimeout = (scsiErrorBase+0x0A), // -7926 = Target selection timeout
- scsiCommandTimeout = (scsiErrorBase+0x0B), // -7925 = Command timeout
- scsiIdentifyMessageRejected = (scsiErrorBase+0x0C), // -7924 =
- scsiMessageRejectReceived = (scsiErrorBase+0x0D), // -7923 = Message reject received
- scsiSCSIBusReset = (scsiErrorBase+0x0E), // -7922 = SCSI bus reset sent/received
- scsiParityError = (scsiErrorBase+0x0F), // -7921 = Uncorrectable parity error occured
- scsiAutosenseFailed = (scsiErrorBase+0x10), // -7920 = Autosense: Request sense cmd fail
- scsiUnused11 = (scsiErrorBase+0x11), // -7919 =
- scsiDataRunError = (scsiErrorBase+0x12), // -7918 = Data overrun/underrun error
- scsiUnexpectedBusFree = (scsiErrorBase+0x13), // -7917 = Unexpected BUS free
- scsiSequenceFailed = (scsiErrorBase+0x14), // -7916 = Target bus phase sequence failure
- scsiWrongDirection = (scsiErrorBase+0x15), // -7915 = Data phase was in unexpected direction
- scsiUnused16 = (scsiErrorBase+0x16), // -7914 =
- scsiBDRsent = (scsiErrorBase+0x17), // -7913 = A SCSI BDR msg was sent to target
- scsiTerminated = (scsiErrorBase+0x18), // -7912 = PB request terminated by the host
- scsiNoNexus = (scsiErrorBase+0x19), // -7911 = Nexus is not established
- scsiCDBReceived = (scsiErrorBase+0x1A), // -7910 = The SCSI CDB has been received
-
- // Couldn't begin execution 30-3F
- scsiTooManyBuses = (scsiErrorBase+0x30), // -7888 = Register failed because we're full
- scsiBusy = (scsiErrorBase+0x31), // -7887 = SCSI subsystem is busy
- scsiProvideFail = (scsiErrorBase+0x32), // -7886 = Unable to provide requ. capability
- scsiDeviceNotThere = (scsiErrorBase+0x33), // -7885 = SCSI device not installed/there
- scsiNoHBA = (scsiErrorBase+0x34), // -7884 = No HBA detected Error
- scsiDeviceConflict = (scsiErrorBase+0x35), // -7883 = sorry, max 1 refNum per DeviceIdent
- scsiNoSuchXref = (scsiErrorBase+0x36), // -7882 = no such RefNum xref
- scsiQLinkInvalid = (scsiErrorBase+0x37), // -7881 = pre-linked PBs not supported (QLink field nonzero)
-
- // Parameter errors 40-7F
- scsiPBLengthError = (scsiErrorBase+0x40), // -7872 = length (scsiPBLength) is insuf'ct/invalid
- scsiFunctionNotAvailable = (scsiErrorBase+0x41), // -7871 = The requ. func is not available
- scsiRequestInvalid = (scsiErrorBase+0x42), // -7970 = PB request is invalid
- scsiBusInvalid = (scsiErrorBase+0x43), // -7969 = Bus ID supplied is invalid
- scsiTIDInvalid = (scsiErrorBase+0x44), // -7868 = Target ID supplied is invalid
- scsiLUNInvalid = (scsiErrorBase+0x45), // -7867 = LUN supplied is invalid
- scsiIIDInvalid = (scsiErrorBase+0x46), // -7866 = The initiator ID is invalid
- scsiDataTypeInvalid = (scsiErrorBase+0x47), // -7865 = scsiDataType requested is not supported
- scsiTransferTypeInvalid = (scsiErrorBase+0x48), // -7864 = scsiTransferType field is too high
- scsiCDBLengthInvalid = (scsiErrorBase+0x49) // -7863 = scsiCDBLength field is too big
- };
-
- #define scsiExecutionErrors scsiErrorBase
- #define scsiNotExecutedErrors scsiTooManyBuses
- #define scsiParameterErrors scsiPBLengthError
-
- //———————————————————————————————————————————————————————————————————————————————————
- // Defines for the scsiResultFlags field
- //———————————————————————————————————————————————————————————————————————————————————
-
- #define scsiSIMQFrozen 0x0001 // The SIM queue is frozen w/this err
- #define scsiAutosenseValid 0x0002 // Autosense data valid for target
- #define scsiBusNotFree 0x0004 // At time of callback, SCSI bus is not free
-
-
- //———————————————————————————————————————————————————————————————————————————————————
- // Defines for the scsiFlags field in the PB header for the SCSIExecIO function
- //———————————————————————————————————————————————————————————————————————————————————
-
- enum
- {
- // 1st Byte
-
- kbSCSIDisableAutosense = 29, // Disable auto sense feature
- kbSCSIFlagReservedA = 28, //
-
- kbSCSIFlagReserved0 = 27, //
- kbSCSICDBLinked = 26, // The PB contains a linked CDB
- kbSCSIQEnable = 25, // Target queue actions are enabled
- kbSCSICDBIsPointer = 24, // The CDB field contains a pointer
-
- // 2nd Byte
-
- kbSCSIFlagReserved1 = 23, //
- kbSCSIInitiateSyncData = 22, // Attempt Sync data xfer and SDTR
- kbSCSIDisableSyncData = 21, // Disable sync, go to async
- kbSCSISIMQHead = 20, // Place PB at the head of SIM Q
-
- kbSCSISIMQFreeze = 19, // Return the SIM Q to frozen state
- kbSCSISIMQNoFreeze = 18, // Disallow SIM Q freezing
- kbSCSIDoDisconnect = 17, // Definitely do disconnect
- kbSCSIDontDisconnect = 16, // Definitely don't disconnect
-
- // 3rd Byte
-
- kbSCSIDataReadyForDMA = 15, // Data buffer(s) are ready for DMA
- kbSCSIFlagReserved3 = 14, //
- kbSCSIDataPhysical = 13, // SG/Buffer data ptrs are physical
- kbSCSISensePhysical = 12, // Autosense buffer ptr is physical
-
- kbSCSIFlagReserved5 = 11, //
- kbSCSIFlagReserved6 = 10, //
- kbSCSIFlagReserved7 = 9, //
- kbSCSIFlagReserved8 = 8, //
-
- // 4th Byte - Target Mode Flags
-
- kbSCSIDataBufferValid = 7, // Data buffer valid
- kbSCSIStatusBufferValid = 6, // Status buffer valid
- kbSCSIMessageBufferValid = 5, // Message buffer valid
- kbSCSIFlagReserved9 = 4, //
-
- kbSCSITargetPhaseMode = 3, // The SIM will run in phase mode
- kbSCSITargetPBAvail = 2, // Target PB available
- kbSCSIDisableAutoDisconnect = 1, // Disable autodisconnect
- kbSCSIDisableAutoSaveRestore= 0 // Disable autosave/restore ptrs
- };
-
-
- // 1st Byte
-
- #define scsiDirectionMask 0xC0000000 // Data direction mask
-
- #define scsiDirectionNone 0xC0000000 // Data direction (11: no data)
- #define scsiDirectionReserved 0x00000000 // Data direction (00: reserved)
- #define scsiDirectionOut 0x80000000 // Data direction (10: DATA OUT)
- #define scsiDirectionIn 0x40000000 // Data direction (01: DATA IN)
- #define scsiDisableAutosense 0x20000000 // Disable auto sense feature
- #define scsiFlagReservedA 0x10000000 //
-
- #define scsiFlagReserved0 0x08000000 //
- #define scsiCDBLinked 0x04000000 // The PB contains a linked CDB
- #define scsiQEnable 0x02000000 // Target queue actions are enabled
- #define scsiCDBIsPointer 0x01000000 // The CDB field contains a pointer
-
- // 2nd Byte
-
- #define scsiFlagReserved1 0x00800000 //
- #define scsiInitiateSyncData 0x00400000 // Attempt Sync data xfer and SDTR
- #define scsiDisableSyncData 0x00200000 // Disable sync, go to async
- #define scsiSIMQHead 0x00100000 // Place PB at the head of SIM Q
-
- #define scsiSIMQFreeze 0x00080000 // Return the SIM Q to frozen state
- #define scsiSIMQNoFreeze 0x00040000 // Disallow SIM Q freezing
- #define scsiDoDisconnect 0x00020000 // Definitely do disconnect
- #define scsiDontDisconnect 0x00010000 // Definitely don't disconnect
-
- // 3rd Byte
-
- #define scsiDataReadyForDMA 0x00008000 // Data buffer(s) are ready for DMA
- #define scsiFlagReserved3 0x00004000 //
- #define scsiDataPhysical 0x00002000 // SG/Buffer data ptrs are physical
- #define scsiSensePhysical 0x00001000 // Autosense buffer ptr is physical
-
- #define scsiFlagReserved5 0x00000800 //
- #define scsiFlagReserved6 0x00000400 //
- #define scsiFlagReserved7 0x00000200 //
- #define scsiFlagReserved8 0x00000100 //
-
- // 4th Byte - Target Mode Flags
-
- #define scsiDataBufferValid 0x00000080 // Data buffer valid
- #define scsiStatusBufferValid 0x00000040 // Status buffer valid
- #define scsiMessageBufferValid 0x00000020 // Message buffer valid
- #define scsiFlagReserved9 0x00000010 //
-
- #define scsiTargetPhaseMode 0x00000008 // The SIM will run in phase mode
- #define scsiTargetPBAvail 0x00000004 // Target PB available
- #define scsiDisableAutoDisconnect 0x00000002 // Disable autodisconnect
- #define scsiDisableAutoSaveRestore 0x00000001 // Disable autosave/restore ptrs
-
- #define scsiTargetModeFlagsMask 0x000000FF // all of the target mode bits
-
-
-
- //————————————————————————————————————————
- // scsiIOFlags
- //————————————————————————————————————————
-
- #define scsiNoParityCheck 0x0002 // disable parity checking
- #define scsiDisableSelectWAtn 0x0004 // disable select w/Atn
- #define scsiSavePtrOnDisconnect 0x0008 // do SaveDataPointer upon Disconnect msg
- #define scsiNoBucketIn 0x0010 // don’t bit bucket in during this I/O
- #define scsiNoBucketOut 0x0020 // don’t bit bucket out during this I/O
- #define scsiDisableWide 0x0040 // disable wide transfer negotiation
- #define scsiInitiateWide 0x0080 // initiate wide transfer negotiation
- #define scsiRenegotiateSense 0x0100 // renegotiate sync/wide before issuing autosense
-
- #define scsiIOFlagReserved0080 0x0080 //
- #define scsiIOFlagReserved8000 0x8000 //
-
-
- //——————————————————————————————————————————————————————————————————————
- // Defines for the SIM/HBA queue actions. These values are used in the
- // SCSIExecIOPB, for the queue action field. [These values should match the
- // defines from some other include file for the SCSI message phases. We may
- // not need these definitions here. ]
-
- enum {
- scsiSimpleQTag = 0x20, // Tag for a simple queue
- scsiHeadQTag = 0x21, // Tag for head of queue
- scsiOrderedQTag = 0x22 // Tag for ordered queue
- };
-
- //——————————————————————————————————————————————————————————————————————
- // Defines for the Bus Inquiry PB fields.
- //——————————————————————————————————————————————————————————————————————
-
- // scsiHBAInquiry field bits
-
- #define scsiBusMDP 0x80 // Supports Modify Data Pointer message
- #define scsiBusWide32 0x40 // Supports 32 bit wide SCSI
- #define scsiBusWide16 0x20 // Supports 16 bit wide SCSI
- #define scsiBusSDTR 0x10 // Supports Sync Data Transfer Req message
- #define scsiBusLinkedCDB 0x08 // Supports linked CDBs
- #define scsiBusTagQ 0x02 // Supports tag queue message
- #define scsiBusSoftReset 0x01 // Supports soft reset
-
-
- // scsiDataTypes field bits
- // bits 0->15 Apple-defined, 16->30 3rd-party unique, 31 = reserved
-
- #define scsiBusDataTIB (1<<scsiDataTIB) // TIB supplied (ptr in scsiDataPtr)
- #define scsiBusDataBuffer (1<<scsiDataBuffer) // single contiguous buffer supplied
- #define scsiBusDataSG (1<<scsiDataSG) // scatter/gather list supplied
-
- #define scsiBusDataReserved 0x80000000 //
-
-
- // scsiTargetModeFlags field bits
-
- #define scsiBusTargetMdProcessor 0x80 // Target mode processor mode
- #define scsiBusTargetMdPhase 0x40 // Target mode phase cog. mode
-
-
- // scsiScanFlags field bits
-
- #define scsiBusScansDevices 0x80 // Bus scans for and maintains device list
- #define scsiBusScansOnInit 0x40 // Bus scans performed at power-up/reboot
- #define scsiBusLoadsROMDrivers 0x20 // may load ROM drivers to support targets
-
-
- // scsiFeatureFlags field bits
-
- #define scsiBusInternalExternalMask 0x000000C0 // bus internal/external mask
- #define scsiBusInternalExternalUnknown 0x00000000 // not known whether bus is inside or outside
- #define scsiBusInternalExternal 0x000000C0 // bus goes inside and outside the box
- #define scsiBusInternal 0x00000080 // bus goes inside the box
- #define scsiBusExternal 0x00000040 // bus goes outside the box
-
- #define scsiBusCacheCoherentDMA 0x00000020 // DMA is cache coherent
- #define scsiBusOldCallCapable 0x00000010 // SIM is old call capable
-
- #define scsiBusDifferential 0x00000004 // Single Ended (0) or Differential (1)
- #define scsiBusFastSCSI 0x00000002 // HBA supports fast SCSI
- #define scsiBusDMAavailable 0x00000001 // DMA is available
-
-
- // scsiWeirdStuff field bits
-
- #define scsiOddDisconnectUnsafeRead1 0x0001 //
- #define scsiOddDisconnectUnsafeWrite1 0x0002 //
- #define scsiBusErrorsUnsafe 0x0004 //
- #define scsiRequiresHandshake 0x0008 //
- #define scsiTargetDrivenSDTRSafe 0x0010 //
-
-
-
- //———————————————————————————————————————————————————————————————————————————————————
- // Defines for the scsiDriverFlags field (in SCSI_Driver_PB)
- //———————————————————————————————————————————————————————————————————————————————————
-
- #define scsiDeviceSensitive 0x0001 // Only driver should access this device
- #define scsiDeviceNoOldCallAccess 0x0002 // no old call access to this device
-
-
-
- //——————————————————————————————————————————————————————————————————————
- // SIMinitInfo
- //——————————————————————————————————————————————————————————————————————
-
- typedef struct { // directions are for SCSIRegisterBus call ( -> parm, <- result)
- unsigned char * SIMstaticPtr; // <- alloc. ptr to the SIM's static vars
- long staticSize; // -> num bytes SIM needs for static vars
- OSErr (*SIMinit)(); // -> pointer to the SIM init routine
- void (*SIMaction)(); // -> pointer to the SIM action routine
- long (*SIM_ISR)(); // -> pointer to the SIM ISR routine
- long (*SIMInterruptPoll)(); // -> pointer to the SIM interrupt poll routine
- void (*NewOldCall)(); // -> pointer to the SIM NewOldCall routine
- unsigned short ioPBSize; // -> size of SCSI_IO_PBs required for this SIM
- Boolean oldCallCapable; // -> true if this SIM can handle old-API calls
- unsigned char simInfoUnused1; // ->
- long simInternalUse; // xx not affected or viewed by XPT
- void (*XPT_ISR)(); // <- ptr to the XPT ISR
- void (*EnteringSIM)(); // <- ptr to the EnteringSIM routine
- void (*ExitingSIM)(); // <- ptr to the ExitingSIM routine
- void (*MakeCallback)(); // <- pointer to the XPT layer’s MakeCallback routine
- unsigned short busID; // <- bus number for the registered bus
- unsigned short simInfoUnused3; // <-
- long simInfoUnused4; // <-
- } SIMinitInfo;
-
-
-
- /********* Glue between SCSI calls and SCSITrap format ***********/
-
- enum {
- xptSCSIAction = 0x0001,
- xptSCSIRegisterBus = 0x0002,
- xptSCSIDeregisterBus = 0x0003,
- xptSCSIReregisterBus = 0x0004,
- xptSCSIKillXPT = 0x0005 // kills Mini-XPT after transition
- };
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #pragma parameter __D0 SCSIAction(__A0) /* moveq #kSCSIx, D0; _SCSIAtomic */
- OSErr SCSIAction(SCSI_PB *) = {0x7001, _SCSIAtomic};
-
- #pragma parameter __D0 SCSIRegisterBus(__A0)
- OSErr SCSIRegisterBus(SIMinitInfo *) = {0x7002, _SCSIAtomic};
-
- #pragma parameter __D0 SCSIDeregisterBus(__A0)
- OSErr SCSIDeregisterBus(SIMinitInfo *) = {0x7003, _SCSIAtomic};
-
- #pragma parameter __D0 SCSIReregisterBus(__A0)
- OSErr SCSIReregisterBus(SIMinitInfo *) = {0x7004, _SCSIAtomic};
-
- #pragma parameter __D0 SCSIKillXPT(__A0)
- OSErr SCSIKillXPT(SIMinitInfo *) = {0x7005, _SCSIAtomic};
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif __SCSI__
-